﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Compiler
{
    class Accept : ParseTableAction
    {
        public void Execute(
            IEnumerator<LexerPair> sourceEnumerator, 
            Stack<Entry> stack,
            Stack<INode> nodeStack,
            INodeFactory nodeFactory)
        {
            if (nodeFactory != null)
            {
                Debug.Assert(nodeStack.Count == 1);
                throw new AcceptException { RootNode = nodeStack.Pop() };
            }
            else throw new AcceptException();
        }

        public override string ToString()
        {
            return "acc";
        }
    }
}
